<template>
  <div id="app">
    <router-view v-if="isRouterAlive" />
  </div>
</template>

<script>
export default {
  name: "app",
  data() {
    return {
      isRouterAlive: true,
    };
  },
  provide() {
    return {
      reload: this.reload,
    };
  },
  methods: {
    reload() {
      this.isRouterAlive = false;
      this.$nextTick(function () {
        this.isRouterAlive = true;
      });
    },
  },
  created() {
    if (this.$cookies.get("userInfo")) {
      let userInfo = this.$cookies.get("userInfo");
      // 把数据 存到 vuex
      this.$store.state.userInfo = JSON.parse(JSON.stringify(userInfo));
    }
  },
};
</script>

<style lang="scss">
#app {
  // width: 100%;
}
.all {
  // width: 100%;
}
</style>
